<template>
  <div class="status">
      <a-table
          size="small"
          style="margin-top: 10px"
          :pagination="false"
          :columns="columns" :data-source="judgeList">
        <template #bodyCell="{ column, text,index }">
          <div  v-if="column.dataIndex === 'status'">
            <a-tag :color="getTypeByStatus(text).rgb">{{getTypeByStatus(text).name}}</a-tag>
          </div>
          <div v-if="column.dataIndex === 'submitTime'">
           <a @click="goToJudgeDetail(index)">{{parseTime(text,"{m}-{d} {h}:{i}:{s}")}}</a>
          </div>
        </template>
      </a-table>
  </div>
</template>

<script lang="ts" setup>
import {parseTime} from "@/utils/date"
import {getTypeByStatus} from "@/common/enum";
import {computed, reactive, ref} from 'vue';
import router from "@/router";

const props = defineProps({
    judgeList:{
      type:Array,
      default:[]
    }
})

const current = ref(1)
const pageSize = ref(5);


const columns = [
  {
    title: '提交时间',
    dataIndex: 'submitTime',
    key: 'submitTime',
    width: 150
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
  },
  {
    title: '语言',
    dataIndex: 'language',
    key: 'language',
    ellipsis: true,
  },
  {
    title: '耗时/ms',
    dataIndex: 'time',
    key: 'time',
    ellipsis: true,
  },
  {
    title: '内存/kb',
    dataIndex: 'memory',
    key: 'memory',
    ellipsis: true,
  },
];

const data = [
  {
    key:1,
    createTime:"2023-11-01 00:00:00",
    status:0,
    time:300,
    meg:24563,
    lang:"C++"
  }
];

const goToJudgeDetail = (index) => {
  const id = props.judgeList?.[index]?.id
  const c = router.resolve({
    path: `/judge/${id}`,
  });
  window.open(c.href, "_blank");
}

</script>
<style scoped>

</style>
